
package jweslley.ContestVolumes.VolumeCXIV;

import static java.lang.Math.abs;

import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

import jweslley.Problem;
import jweslley.Problem.Status;

/**
 * http://icpcres.ecs.baylor.edu/onlinejudge/external/114/11461.html
 *
 * @author  Jonhnny Weslley
 * @version 1.00, 19/10/2008
 */
@Problem(Status.Accepted)
public class SquareNumbers {

	static final int MAX = 100000;

	public static void main(String[] args) {
		LinkedList<Integer> squareNumbers = new LinkedList<Integer>();
		int i = 1;
		do {
			squareNumbers.add((int)Math.pow(i++, 2));
		} while (squareNumbers.getLast() < MAX);

		StringBuilder out = new StringBuilder();
		Scanner in = new Scanner(System.in);
		int n1, n2, pn1, pn2;		
		while (in.hasNext()) {
			n1 = in.nextInt();
			n2 = in.nextInt();
			if (n1 == 0 && n2 == 0) break;

			pn1 = Collections.binarySearch(squareNumbers, n1);
			pn2 = Collections.binarySearch(squareNumbers, n2);

			pn1 = pn1 < 0 ? abs(pn1) - 1 : pn1;
			pn2 = pn2 < 0 ? abs(pn2) - 1 : pn2 + 1;
			out
			.append(pn2 - pn1)
			.append('\n');
		}
		System.out.print(out);
	}

}
